class UserManager{
    static getInstance(){
        if (!UserManager._instance) {
            UserManager._instance = new UserManager();
        }
        return UserManager._instance;
    }
    constructor(){
        this.users = [];
    }
    addUser(user){
        this.users.push(user);
        console.log("用户管理器中有：" + this.users.length + "用户");
    }
    removeUser(user){
        let index = this.users.indexOf(user);
        if (index > -1) {
            this.users.splice(index,1);
        }
        console.log(index);
        console.log("用户管理器中有：" + this.users.length + "用户");
    }
    getUserByUid(uid){
        let user = null;
        for(let i = 0; i < this.users.length; i++){
            if (this.users[i].getUid() == uid){
                user = this.users[i];
                break;
            }
        }
        return user;
    }
}
UserManager._instance = null;
module.exports = UserManager;